﻿namespace WLFramework.Security
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class MD5Hash : AlgorithmHash, IChecksum
    {
        public MD5Hash()
            :base(System.Security.Cryptography.MD5.Create())
        {
        }

        public override long Value
        {
            get
            {
                return hash == null ? 0 : BitConverter.ToInt64(hash, 8);
            }
        }

        public override string HashCode
        {
            get
            {
                if (hash == null) return string.Empty;
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < this.hash.Length; i++)
                {
                    sb.Append(this.hash[i].ToString("x2"));
                }

                return sb.ToString();
            }
        }
    }
}
